
global Educ i.NOLevels_E23 i.NALevels_E23 Degree_E23 Voc2_E23 HQual_E23

mat define f=J(1,6,.)


local i=1
foreach a of numlist 23 33 42 46 50 55{
qui rifhdreg lwage_I`a' $Controls CogAbility creativityt_sd_7 [pweight=1/pObs_I`a'], rob rif(mean)
est sto e`a'
mat f[1,`i']=_b[creativityt_sd_7]
local i=`i'+1
}

esttab e* using results/Tables/R_OLS_wageeduc.tex, ///
replace se star(* 0.1 ** 0.05 *** 0.01) b(%9.3f) se(%9.3f) nonumbers collabels(none) ///
keep(creativityt_sd_7) ///
order(creativityt_sd_7) ///
refcat(creativityt_sd_7 " "  " " "", nolabel) ///
varlabels(creativityt_sd_7 "Without controls for education") ///
cells(b(star fmt(3)) se(par) ".") nogaps   alignment(c) frag ///
mtitles("Age 23" "Age 33" "Age 42" "Age 46" "Age 50" "Age 55") ///
posthead(\cline{2-7})  noobs   
est drop _all


 

local i=1
foreach a of numlist 23 33 42 46 50 55{
qui rifhdreg lwage_I`a' $Controls $Educ CogAbility creativityt_sd_7 [pweight=1/pObs_I`a'], rob rif(mean)
scalar ff=1-(f[1,`i']-_b[creativityt_sd_7])/f[1,`i']
disp ff
estadd scalar ff
est sto e`a'
local i=`i'+1
}
esttab e* using results/Tables/R_OLS_wageeduc.tex, ///
append se star(* 0.1 ** 0.05 *** 0.01) b(%9.3f) se(%9.3f) nonumbers collabels(none) ///
keep(creativityt_sd_7) ///
order(creativityt_sd_7) ///
varlabels(creativityt_sd_7 "With controls for education") ///
cells(b(star fmt(3)) se(par) "." ) nogaps   alignment(c) ///
posthead("") nomtitles frag  ///
stats(ff  N , fmt( %9.3f  %11.0gc %9.3f) labels("\shortstack[l]{\vphantom{A} \\ Fraction of creativity effect \\ explained by education}" "\vphantom{A}\\ Observations"))


